package com.qf.commons.mysql.utils;


import com.qf.data.page.Page;

/**
 * description: 分页的工具类 - ThreadLocal用来存储当前请求的Page对象
 * author: Ken
 * 公众号：Java架构栈
 */
public class QphonePage {

    private static ThreadLocal<Page> pageThreadLocal = new ThreadLocal<>();

    /**
     * 设置分页信息
     */
    public static void setPage(Integer pageNum, Integer pageSize){
        Page page = new Page();
        page.setPageNum(pageNum);
        page.setPageSize(pageSize);
        pageThreadLocal.set(page);
    }

    /**
     * 获取分页信息
     */
    public static Page getPage(){
        return pageThreadLocal.get();
    }

    /**
     * 清楚ThreadLocal
     */
    public static void clear(){
        pageThreadLocal.remove();
    }

}
